package com.link.base.base.product.service;

import com.link.base.base.coupons.model.Coupons;
import com.link.base.base.coupons.service.CouponsService;
import com.link.base.base.product.dao.mybatis.mapper.GuideProdMapper;
import com.link.base.base.product.model.*;
import com.link.core.basic.dao.mapper.BasicMapper;
import com.link.core.basic.service.BasicServiceImpl;
import com.link.base.base.product.model.Product;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liying
 * @date 2018/12/03
 * @comments h5产品操作服务
 */
@Service
public class GuideProdServiceImpl extends BasicServiceImpl<Product> implements GuideProdService {

    @Resource
    private GuideProdMapper guideProductMapper;

    @Resource
    private CouponsService couponsService;

    @Override
    public BasicMapper<Product> getBasicMapper() {
        return guideProductMapper;
    }

    @Override
    public Product queryById(Product entity) throws Exception {
        entity = super.queryById(entity);
        List<Coupons> list = (List<Coupons>) couponsService.productForCard(entity).get("rows");
        entity.setCouponsList(list);
        return entity;
    }
}
